<template>
    <!-- EXAMPLE: 在layer.vue中实现地图功能 -->
  <Mars3dLayer ref="mars3dRef" v-if="mapInstance.value?.type === MARS3D_NAME" />
  <AcLayer ref="acRef" v-if="mapInstance.value?.type === AC_NAME" />
</template>
<script lang="ts" setup>
import { inject, onMounted, ref } from 'vue';
import Mars3dLayer from './components/mars3d-layer/index.vue';
import AcLayer from './components/ac-layer/index.vue';

const main = inject<any>('main');
const { mapInstance, AC_NAME, MARS3D_NAME }: any = main;

const mars3dRef = ref(null);
const acRef = ref(null);

/** 绘制多边形 */
const drawPolygon = () => {
  mapInstance.value?.type === MARS3D_NAME ? mars3dRef.value.drawPolygon() : acRef.value.drawPolygon();
};

onMounted(() => {
  drawPolygon()
})

</script>
